import { Tag } from 'ant-design-vue';
import type { TableColumn } from '@/components/core/dynamic-table';

export type TableListItem = API.DictListResultItem;
export type TableColumnItem = TableColumn<TableListItem>;

export const baseColumns: TableColumnItem[] = [
  {
    title: '字典编号',
    dataIndex: 'no',
    align: 'center',
    hideInSearch: true,
  },
  {
    title: '字典名称',
    dataIndex: 'name',
    align: 'center',
  },
  {
    title: '字典类型',
    dataIndex: 'dataType',
    align: 'center',
    hideInSearch: true,
    customRender: ({ record }) => (
      <Tag color={record.dataType == '0' ? 'green' : record.dataType == '1' ? 'yellow' : 'red'}>
        {record.dataType == '0' ? '静态数据' : record.dataType == '1' ? 'SQL数据' : '接口数据'}
      </Tag>
    ),
    formItemProps: {
      component: 'Select',
      componentProps: () => ({
        options: [
          {
            label: '静态数据',
            value: '0',
          },
          {
            label: 'SQL数据',
            value: '1',
          },
          {
            label: '接口数据',
            value: '2',
          },
        ],
      }),
    },
  },
  {
    title: '状态',
    dataIndex: 'status',
    align: 'center',
    customRender: ({ record }) => (
      <Tag color={record.status == '0' ? 'red' : 'blue'}>
        {record.status == '0' ? '停用' : '正常'}
      </Tag>
    ),
    formItemProps: {
      component: 'Select',
      componentProps: () => ({
        options: [
          {
            label: '停用',
            value: '0',
          },
          {
            label: '正常',
            value: '1',
          },
        ],
      }),
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    align: 'center',
    hideInSearch: true,
  },
  {
    title: '值',
    dataIndex: 'doc',
    align: 'center',
    hideInSearch: true,
  },
];
